package com.redsoil.house.widget;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.redsoil.house.R;
import com.redsoil.house.ui.matter.activity.MatterFileListActivity;
import com.zhy.autolayout.AutoLinearLayout;

/**
 * Created by weidingqiang on 2018/12/18.
 */

public class PropertyFileItem extends AutoLinearLayout {

    private AutoLinearLayout property_file_item_layout;

    private ImageView property_file_icon_img;

    private TextView property_file_title;

    private TextView property_file_value;

    private ImageView property_file_more_img;

    public PropertyFileItem(Context context) {
        this(context,null);
    }

    public PropertyFileItem(Context context, AttributeSet attrs) {
        super(context, attrs);

        LayoutInflater inflater = LayoutInflater.from(context);
        inflater.inflate(R.layout.property_file_item, this, true);

        property_file_item_layout = (AutoLinearLayout) this.findViewById(R.id.property_file_item_layout);

        property_file_icon_img = (ImageView) this.findViewById(R.id.property_file_icon_img);

        property_file_title = (TextView) this.findViewById(R.id.property_file_title);

        property_file_value = (TextView) this.findViewById(R.id.property_file_value);

        property_file_more_img = (ImageView) this.findViewById(R.id.property_file_more_img);

    }

    /**
     * 传图标 内容 数量 背景
     */
    public void setData(Integer icon,String title,String value,Drawable bg){

        property_file_item_layout.setBackground(bg);

        Glide.with(getContext()).load(icon).into(property_file_icon_img);

        property_file_title.setText(title);

        property_file_value.setText(value);

        if(value.equals("0")){
            property_file_more_img.setVisibility(INVISIBLE);
            property_file_value.setVisibility(INVISIBLE);
        }
    }

}
